Skip to main content

Create Materialized Views

๐Ÿ“„ <ENV> - [BigQuery] Create BigQuery Materialized Viewโ€‹

This GitHub Actions workflow is designed to manually trigger the creation of a BigQuery Materialized View using a TypeScript helper script. It authenticates with GCP using a service account and runs the logic defined in the specified TypeScript file.


๐Ÿ“Œ Workflow Triggerโ€‹

This workflow is triggered manually via the GitHub actions in functions repo

Required Input:โ€‹

  • table_name (string): The BigQuery latest table name for which the materialized view should be created.

๐Ÿ’  Environment Variablesโ€‹

VariableDescription
GCP_PROJECT_IDGCP Project ID (e.g., biddirect-2)
TABLE_NAMEName of the latest BigQuery table (input)


๐Ÿš€ Job: deploy-bigquery-materialized-viewโ€‹

StepDescription
Checkout repositoryClones the repo.
Set project env variableStores the GCP project ID in the GitHub Actions environment.
Set table name variableStores the input table_name in the GitHub Actions environment.
Authenticate with GCPAuthenticates using a service account (ENV_BIGQUERY_ADMIN_SERVICE_ACCOUNT) stored in GitHub Secrets.
Set up Cloud SDKInstalls and sets up the Google Cloud SDK CLI.
Install dependenciesRuns npm install inside the functions directory.
Create materialized viewExecutes the helper script createMaterializedView.ts using npx ts-node.

๐Ÿงน Script Locationโ€‹

The script responsible for creating the BigQuery Materialized View is located at:

functions/src/bqDataLake/definitions/views/helpers/createMaterializedView.ts

Make sure this script handles:

  • Connecting to BigQuery using the provided credentials.
  • Creating the desired materialized view using the given TABLE_NAME.

๐Ÿ” Required Secretsโ€‹

Secret NameDescription
<ENV>_BIGQUERY_ADMIN_SERVICE_ACCOUNTService account key JSON for GCP auth.

โœ… Example Usageโ€‹

To run this workflow:

  1. Go to the Actions tab in your GitHub repository.
  2. Select the workflow <ENV> - [BigQuery] Create BigQuery Materialized View.
  3. Enter the table_name (e.g., accounts_latest).
  4. Click "Run workflow".